const express = require('express')
const router = express.Router()

const {
  createGroup,
  updateGroup,
  deleteGroup,
  getGroup,
  getImages,
  deleteImage,
  recoverImage,
  getDeleteImages,
} = require('../router_handler/group')

const expressJoi = require('@escook/express-joi')

const {
  createGroup_schema,
  updateGroup_schema,
  deleteGroup_schema,
  getGroupImages_schema,
  deleteImage_schema,
  recoverImage_schema,
  getDeleteImages_schema,
} = require('../schema/group')

//
//
/**
 * 创建新组
 * @param groupName 组名
 */
router.post('/create', expressJoi(createGroup_schema), createGroup)

/**
 * 修改组名
 * @param groupId 组id
 * @param groupName 组名
 */
router.post('/update', expressJoi(updateGroup_schema), updateGroup)

/**
 * 删除组
 * @param groupId 组 id
 */
router.delete('/delete', expressJoi(deleteGroup_schema), deleteGroup)

/**
 * 获取用户所有组的信息
 */
router.get('/get', getGroup)

/**
 * 分页获取组中的图片
 * @param groupId
 * @param page
 * @param pageSize
 */
router.get('/getImages', expressJoi(getGroupImages_schema), getImages)

/**
 * 删除图片
 * @param imageId
 */
router.delete('/deleteImage', expressJoi(deleteImage_schema), deleteImage)

/**
 * 恢复图片
 * @param imageId
 */
router.post('/recoverImage', expressJoi(recoverImage_schema), recoverImage)

/**
 * 分页获取删除的图片
 * @param page
 * @param pageSize
 */
router.get(
  '/getDeleteImages',
  expressJoi(getDeleteImages_schema),
  getDeleteImages
)

//
//
module.exports = router
